package com.clkj.xiuzheng.config;

import com.clkj.xiuzheng.pojo.common.ApplicationContextUtil;
import com.clkj.xiuzheng.service.UserService;
import com.clkj.xiuzheng.service.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * @author yawang
 * @create 2024/03/15 09:10:14
 **/
public class CloseTask implements Runnable{
    @Autowired
    private RedisTemplate redisTemplate =(RedisTemplate) ApplicationContextUtil.getBean("redisTemplate");

    @Autowired
    private UserService userService = (UserService) ApplicationContextUtil.getBean("UserServiceImpl");


    private String shopIds,recordId;


    public CloseTask(String shopIds,String  recordId) {
        System.out.println(recordId);

        this.shopIds =shopIds;
        this.recordId =recordId;
    }

    @Override
    public void run() {
        boolean times = redisTemplate.hasKey("recordId"+recordId);
        System.out.println(times);
        if(times){
            userService.updateShopStatus(shopIds,recordId);
        }
    }
}
